Class NewsUserActorTest

java.lang.Object
com.fsf.news.actor.websocket.NewsUserActorTest

@ExtendWith({org.mockito.junit.jupiter.MockitoExtension.class,org.apache.pekko.actor.testkit.typed.javadsl.TestKitJUnit5Extension.class}) class NewsUserActorTest extends Object
Unit tests for the NewsUserActor class.
  • Field Details

    • testKit

      @JUnit5TestKit org.apache.pekko.actor.testkit.typed.javadsl.ActorTestKit testKit
    • factory

      @Mock com.fsf.news.actor.websocket.factory.NewsWorkerActorFactory factory
    • objectMapper

      @Mock com.fasterxml.jackson.databind.ObjectMapper objectMapper
    • node

      @Mock com.fasterxml.jackson.databind.JsonNode node
  • Constructor Details

    • NewsUserActorTest

      NewsUserActorTest()
  • Method Details

    • testCreateMessage

      @Test void testCreateMessage()
      Tests that a Create message triggers creation of a worker session via the factory.
    • testCloseMessage

      @Test void testCloseMessage()
      Tests that sending a Close message terminates the user actor session.
    • testCloseMessageWithWorker

      @Test void testCloseMessageWithWorker()
      Confirms proper termination of the user actor along with a stopped worker.
    • testCreateMessageMultipleDuplicateUserSesssions

      @Test void testCreateMessageMultipleDuplicateUserSesssions()
      Tests that multiple duplicate Create messages use the same WebSocket flow.
    • testCreateMessageFlowToWorker

      @Test void testCreateMessageFlowToWorker() throws com.fasterxml.jackson.core.JsonProcessingException
      Tests that a WebSocket flow forwards messages to the corresponding worker.
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if JSON parsing fails during testing
    • testCreateMessageSupervision

      @Test void testCreateMessageSupervision()
      Tests supervision of a worker actor, ensuring it restarts after failure.
    • testCreateMessageSupervisionRetryLimit

      @Test void testCreateMessageSupervisionRetryLimit()
      Confirms that retries stop after reaching the configured limit.